import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'


Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'Home',
    component: Home,
    redirect:"/login",
    children:[
      {
        path:'/index',
        name:'index',
        component:()=>import("@/views/indexs/index")
      },
      {
        path:'/user',
        name:'user',
        component:()=>import("@/views/users/userList")
      },
      {
        path:'/admin',
        name:'admin',
        component:()=>import("@/views/users/adminList")
      }, //
      {
        path:'/navigation/nav',
        name:'nav',
        component:()=>import("@/views/navigation/nav")
      },{
        path:'/file/map',
        name:'mapList',
        component:()=>import("@/views/file/mapList")
      },{
        path:'/file/recycle',
        name:'recycle',
        component:()=>import("@/views/file/recycle")
      },{
        path:'/advertise/list',
        name:'List',
        component:()=>import("@/views/advertise/List")
      },{
        path:'/article/cate',
        name:'Cate',
        component:()=>import("@/views/article/Cate")
      },{
        path:'/article/list',
        name:'List',
        component:()=>import("@/views/article/List")
      },{
        path:'/article/replay/:id',
        name:'Replay',
        component:()=>import("@/views/article/Replay")
      },{
        path:'/information/list',
        name:'List',
        component:()=>import("@/views/information/List")
      },{
        path:'/klasa/class',
        name:'Class',
        component:()=>import("@/views/klasa/Class")
      },{
        path:'/klasa/course',
        name:'Course',
        component:()=>import("@/views/klasa/Course")
      },{
        path:'/klasa/sc',
        name:'Sc',
        component:()=>import("@/views/klasa/Sc")
      },{
        path:'/klasa/addsc',
        name:'AddSc',
        component:()=>import("@/views/klasa/AddSc")
      },{
        path:'/klasa/task',
        name:'taskList',
        component:()=>import("@/views/task/taskList")
      },{
        path:'/control/temp',
        name:'temp',
        component:()=>import("@/views/control/temp")
      },{
        path:'/control/access',
        name:'access',
        component:()=>import("@/views/control/access")
      },{
        path:'/chat/online',
        name:'OnLine',
        component:()=>import("@/views/chat/OnLine")
      },{
        path:'/chat/chatrecord',
        name:'ChatRecord',
        component:()=>import("@/views/chat/ChatRecord")
      }
    ]
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('@/views/Login.vue')
  }
]

const router = new VueRouter({
  mode: 'hash',
  base: process.env.BASE_URL,
  routes
})

// router.beforeEach()
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

export default router
